/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Telas;

import Conexao.ConectaBD;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;



/**
 *
 * @author Thalyson
 */
public class Tela_Contatos extends javax.swing.JFrame {

    Connection conecta;
    PreparedStatement pst;
    ResultSet rs;
    
    public Tela_Contatos() throws ClassNotFoundException {
        initComponents();
        setSize(805, 553);
        setLocationRelativeTo(null);
        conecta = ConectaBD.conectabd();
        listarContatos();
        Icon();
    }
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    private void Icon(){
    
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("assistec_icon.png")));
        
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void listarContatos() {
        String sql = "Select *from contato order by Nome Asc";
        try {
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();
            jt_contato.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void cadastrarContatos() {
        String sql = "Insert into contato (Nome,Tipo_Contato,Telefone1,Telefone2,Telefone3,Celular,Email) values(?,?,?,?,?,?,?)";
        
        if(tf_nome.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Nome é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_tipocontato.getSelectedItem().equals("TIPO DE CONTATO")){
        JOptionPane.showMessageDialog(null, "Campo Tipo de Contato é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jf_telefone1.getText().equals("(  )    -    ")){
        JOptionPane.showMessageDialog(null, "Campo Telefone é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        
        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_nome.getText());
            pst.setString(2, cb_tipocontato.getSelectedItem().toString());
            pst.setString(3, jf_telefone1.getText());
            pst.setString(4, jf_telefone2.getText());
            pst.setString(5, jf_telefone3.getText());
            pst.setString(6, jf_celular.getText());
            pst.setString(7, tf_email.getText());

            pst.execute();
            JOptionPane.showMessageDialog(null, "Registrado com Sucesso!", "Registrado com Sucesso", JOptionPane.INFORMATION_MESSAGE);
            listarContatos();
            Limpar();

        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void pesquisarContatos() {
        String sql = "Select *from contato where Nome like ?";

        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_pesquisar.getText() + "%");
            rs = pst.executeQuery();
            jt_contato.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void mostraContatos() {
        int seleciona = jt_contato.getSelectedRow();
        tf_id.setText(jt_contato.getModel().getValueAt(seleciona, 0).toString());
        tf_nome.setText(jt_contato.getModel().getValueAt(seleciona, 1).toString());
        cb_tipocontato.setSelectedItem(jt_contato.getModel().getValueAt(seleciona, 2).toString());
        jf_telefone1.setText(jt_contato.getModel().getValueAt(seleciona, 3).toString());
        jf_telefone2.setText(jt_contato.getModel().getValueAt(seleciona, 4).toString());
        jf_telefone3.setText(jt_contato.getModel().getValueAt(seleciona, 5).toString());
        jf_celular.setText(jt_contato.getModel().getValueAt(seleciona, 6).toString());
        tf_email.setText(jt_contato.getModel().getValueAt(seleciona, 7).toString());
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void editarContatos() {
        String sql = "Update contato set Nome = ?,Tipo_Contato = ?,Telefone1 = ?,Telefone2 = ?,Telefone3 = ?,Celular = ?,Email = ? where id = ? ";
        
        if(cb_tipocontato.getSelectedItem().equals("TIPO DE CONTATO")){
        JOptionPane.showMessageDialog(null, "Campo Tipo de Contato é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        
        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_nome.getText());
            pst.setString(2, cb_tipocontato.getSelectedItem().toString());
            pst.setString(3, jf_telefone1.getText());
            pst.setString(4, jf_telefone2.getText());
            pst.setString(5, jf_telefone3.getText());
            pst.setString(6, jf_celular.getText());
            pst.setString(7, tf_email.getText());
            pst.setInt(8, Integer.parseInt(tf_id.getText()));
            pst.executeUpdate();
            JOptionPane.showMessageDialog(null, "Contato atualizado com sucesso");
            listarContatos();

        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void deletarContatos() {
        String sql = "Delete from contato where id = ?";

        try {
            pst = conecta.prepareStatement(sql);
            pst.setInt(1, Integer.parseInt(tf_id.getText()));
            pst.execute();
            listarContatos();
        } catch (SQLException error) {

            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

            public void Novo(){
            
                try {
                    
                tf_nome.setEditable(true);              
                jf_telefone1.setEditable(true);
                jf_telefone2.setEditable(true);
                jf_telefone3.setEditable(true);
                jf_celular.setEditable(true);
                tf_email.setEditable(true);
                cb_tipocontato.setEnabled(true);
                jb_salvar.setEnabled(true);
                
                Limpar();
                    
                } catch (Exception e) {
                }
                
            }
            
//<----------------------------------------------------------------------------------------------------------------------------------------->    

                public void Limpar() {
                                           
                    tf_nome.setText("");
                    cb_tipocontato.setSelectedItem("TIPO DE CONTATO");
                    tf_id.setText("");
                    tf_pesquisar.setText("");
                    tf_email.setText("");
                    jf_telefone1.setText("");
                    jf_telefone2.setText("");
                    jf_telefone3.setText("");
                    jf_celular.setText("");
                }    
    

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel11 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        tf_nome = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        tf_email = new javax.swing.JTextField();
        tf_id = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        tf_pesquisar = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jt_contato = new javax.swing.JTable();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel30 = new javax.swing.JLabel();
        jb_salvar = new javax.swing.JButton();
        jb_editar = new javax.swing.JButton();
        jb_excluir = new javax.swing.JButton();
        jb_limpar = new javax.swing.JButton();
        jb_fechar = new javax.swing.JButton();
        jf_telefone1 = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cb_tipocontato = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jf_telefone2 = new javax.swing.JFormattedTextField();
        jLabel8 = new javax.swing.JLabel();
        jf_telefone3 = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        jf_celular = new javax.swing.JFormattedTextField();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel23 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("AssisTec - Contatos");
        setResizable(false);
        getContentPane().setLayout(null);

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("CONTATOS");
        getContentPane().add(jLabel11);
        jLabel11.setBounds(680, 170, 80, 14);

        jLabel10.setBackground(new java.awt.Color(255, 255, 255));
        jLabel10.setForeground(new java.awt.Color(78, 78, 78));
        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_agenda.jpg"))); // NOI18N
        jLabel10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        getContentPane().add(jLabel10);
        jLabel10.setBounds(640, 10, 150, 150);

        tf_nome.setEditable(false);
        tf_nome.setBackground(new java.awt.Color(255, 255, 255));
        tf_nome.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_nome.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_nome.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_nome);
        tf_nome.setBounds(10, 30, 360, 30);

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("NOME DO CONTATO");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(10, 10, 130, 14);

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("EMAIL");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(10, 130, 40, 14);

        tf_email.setEditable(false);
        tf_email.setBackground(new java.awt.Color(255, 255, 255));
        tf_email.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_email.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_email.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_email);
        tf_email.setBounds(10, 150, 240, 30);

        tf_id.setEditable(false);
        tf_id.setBackground(new java.awt.Color(255, 255, 255));
        tf_id.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_id.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_id.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_id);
        tf_id.setBounds(580, 130, 50, 30);

        jLabel14.setBackground(new java.awt.Color(255, 255, 255));
        jLabel14.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("ID");
        getContentPane().add(jLabel14);
        jLabel14.setBounds(580, 110, 30, 20);

        tf_pesquisar.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_pesquisar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_pesquisar.setSelectionColor(new java.awt.Color(0, 0, 0));
        tf_pesquisar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tf_pesquisarKeyReleased(evt);
            }
        });
        getContentPane().add(tf_pesquisar);
        tf_pesquisar.setBounds(510, 210, 280, 30);

        jLabel15.setBackground(new java.awt.Color(255, 255, 255));
        jLabel15.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("PESQUISAR CONTATO");
        getContentPane().add(jLabel15);
        jLabel15.setBounds(510, 190, 140, 14);

        jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_lupa.png"))); // NOI18N
        getContentPane().add(jLabel16);
        jLabel16.setBounds(490, 210, 20, 30);

        jt_contato.setAutoCreateRowSorter(true);
        jt_contato.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jt_contato.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jt_contato.setSelectionBackground(new java.awt.Color(0, 0, 0));
        jt_contato.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_contatoMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jt_contato);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(0, 250, 800, 190);

        jSeparator2.setForeground(new java.awt.Color(255, 255, 255));
        getContentPane().add(jSeparator2);
        jSeparator2.setBounds(70, 460, 730, 10);

        jLabel30.setBackground(new java.awt.Color(255, 255, 255));
        jLabel30.setForeground(new java.awt.Color(255, 255, 255));
        jLabel30.setText("AssisTec");
        getContentPane().add(jLabel30);
        jLabel30.setBounds(10, 450, 60, 14);

        jb_salvar.setBackground(new java.awt.Color(255, 255, 255));
        jb_salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_salvar.png"))); // NOI18N
        jb_salvar.setText("SALVAR");
        jb_salvar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_salvar.setBorderPainted(false);
        jb_salvar.setEnabled(false);
        jb_salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_salvarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_salvar);
        jb_salvar.setBounds(290, 470, 100, 50);

        jb_editar.setBackground(new java.awt.Color(255, 255, 255));
        jb_editar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_editar.png"))); // NOI18N
        jb_editar.setText("EDITAR");
        jb_editar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_editar.setBorderPainted(false);
        jb_editar.setEnabled(false);
        jb_editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_editarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_editar);
        jb_editar.setBounds(390, 470, 100, 50);

        jb_excluir.setBackground(new java.awt.Color(255, 255, 255));
        jb_excluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_deletar.png"))); // NOI18N
        jb_excluir.setText("EXCLUIR");
        jb_excluir.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_excluir.setBorderPainted(false);
        jb_excluir.setEnabled(false);
        jb_excluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_excluirActionPerformed(evt);
            }
        });
        getContentPane().add(jb_excluir);
        jb_excluir.setBounds(490, 470, 100, 50);

        jb_limpar.setBackground(new java.awt.Color(255, 255, 255));
        jb_limpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_limpar.png"))); // NOI18N
        jb_limpar.setText("LIMPAR");
        jb_limpar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_limpar.setBorderPainted(false);
        jb_limpar.setEnabled(false);
        jb_limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_limparActionPerformed(evt);
            }
        });
        getContentPane().add(jb_limpar);
        jb_limpar.setBounds(590, 470, 100, 50);

        jb_fechar.setBackground(new java.awt.Color(255, 255, 255));
        jb_fechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fechar.png"))); // NOI18N
        jb_fechar.setText("FECHAR");
        jb_fechar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_fechar.setBorderPainted(false);
        jb_fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_fecharActionPerformed(evt);
            }
        });
        getContentPane().add(jb_fechar);
        jb_fechar.setBounds(690, 470, 100, 50);

        jf_telefone1.setEditable(false);
        jf_telefone1.setBackground(new java.awt.Color(255, 255, 255));
        jf_telefone1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_telefone1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_telefone1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_telefone1.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_telefone1);
        jf_telefone1.setBounds(10, 90, 110, 30);

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("TELEFONE 1");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(10, 70, 90, 14);

        jLabel3.setBackground(new java.awt.Color(255, 255, 255));
        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("TIPO DE CONTATO");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(380, 10, 140, 14);

        cb_tipocontato.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_tipocontato.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TIPO DE CONTATO", "COMERCIAL", "FORNECEDOR", "PESSOAL" }));
        cb_tipocontato.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_tipocontato.setEnabled(false);
        getContentPane().add(cb_tipocontato);
        cb_tipocontato.setBounds(380, 30, 240, 30);

        jLabel7.setBackground(new java.awt.Color(255, 255, 255));
        jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("TELEFONE 2");
        getContentPane().add(jLabel7);
        jLabel7.setBounds(130, 70, 100, 14);

        jf_telefone2.setEditable(false);
        jf_telefone2.setBackground(new java.awt.Color(255, 255, 255));
        jf_telefone2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_telefone2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_telefone2.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_telefone2.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_telefone2);
        jf_telefone2.setBounds(130, 90, 110, 30);

        jLabel8.setBackground(new java.awt.Color(255, 255, 255));
        jLabel8.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("TELEFONE 3");
        getContentPane().add(jLabel8);
        jLabel8.setBounds(250, 70, 110, 14);

        jf_telefone3.setEditable(false);
        jf_telefone3.setBackground(new java.awt.Color(255, 255, 255));
        jf_telefone3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_telefone3.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_telefone3.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_telefone3.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_telefone3);
        jf_telefone3.setBounds(250, 90, 110, 30);

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("CELULAR");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(370, 70, 130, 14);

        jf_celular.setEditable(false);
        jf_celular.setBackground(new java.awt.Color(255, 255, 255));
        jf_celular.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_celular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_celular.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_celular.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_celular);
        jf_celular.setBounds(370, 90, 110, 30);

        jButton2.setBackground(new java.awt.Color(255, 255, 255));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_novo.png"))); // NOI18N
        jButton2.setText("NOVO");
        jButton2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jButton2.setBorderPainted(false);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(10, 470, 100, 50);

        jButton1.setBackground(new java.awt.Color(255, 255, 255));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_atualizar.png"))); // NOI18N
        jButton1.setText("ATUALIZAR");
        jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jButton1.setBorderPainted(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(110, 470, 100, 50);

        jLabel23.setBackground(new java.awt.Color(255, 255, 255));
        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setText("TABELA DE CONTATOS");
        getContentPane().add(jLabel23);
        jLabel23.setBounds(340, 440, 140, 20);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fundo2.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 800, 550);

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void tf_pesquisarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tf_pesquisarKeyReleased
        pesquisarContatos();
    }//GEN-LAST:event_tf_pesquisarKeyReleased

    private void jt_contatoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_contatoMouseClicked
        mostraContatos();
        jb_editar.setEnabled(true);
        jb_limpar.setEnabled(true);
        jb_excluir.setEnabled(true);
        jb_salvar.setEnabled(false);
        
                tf_nome.setEditable(true);              
                jf_telefone1.setEditable(true);
                jf_telefone2.setEditable(true);
                jf_telefone3.setEditable(true);
                jf_celular.setEditable(true);
                tf_email.setEditable(true);
                cb_tipocontato.setEnabled(true);
                jb_salvar.setEnabled(false);
    }//GEN-LAST:event_jt_contatoMouseClicked

    private void jb_salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_salvarActionPerformed
        cadastrarContatos();
    }//GEN-LAST:event_jb_salvarActionPerformed

    private void jb_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_editarActionPerformed
        editarContatos();
    }//GEN-LAST:event_jb_editarActionPerformed

    private void jb_excluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_excluirActionPerformed
        deletarContatos();
    }//GEN-LAST:event_jb_excluirActionPerformed

    private void jb_fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_fecharActionPerformed
        dispose();
    }//GEN-LAST:event_jb_fecharActionPerformed

    private void jb_limparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_limparActionPerformed
                Limpar();
    }//GEN-LAST:event_jb_limparActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        Novo();
        jb_editar.setEnabled(false);
        jb_excluir.setEnabled(false);
        jb_limpar.setEnabled(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        listarContatos();
        jb_editar.setEnabled(false);
        jb_excluir.setEnabled(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Tela_Contatos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Tela_Contatos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Tela_Contatos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Tela_Contatos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new Tela_Contatos().setVisible(true);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Tela_Contatos.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cb_tipocontato;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton jb_editar;
    private javax.swing.JButton jb_excluir;
    private javax.swing.JButton jb_fechar;
    private javax.swing.JButton jb_limpar;
    private javax.swing.JButton jb_salvar;
    private javax.swing.JFormattedTextField jf_celular;
    private javax.swing.JFormattedTextField jf_telefone1;
    private javax.swing.JFormattedTextField jf_telefone2;
    private javax.swing.JFormattedTextField jf_telefone3;
    private javax.swing.JTable jt_contato;
    private javax.swing.JTextField tf_email;
    private javax.swing.JTextField tf_id;
    private javax.swing.JTextField tf_nome;
    private javax.swing.JTextField tf_pesquisar;
    // End of variables declaration//GEN-END:variables
}
